library("tidyverse")
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✔ ggplot2 3.3.6     ✔ purrr   0.3.4
## ✔ tibble  3.1.7     ✔ dplyr   1.0.9
## ✔ tidyr   1.2.0     ✔ stringr 1.4.0
## ✔ readr   2.1.2     ✔ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library("sf")
## Linking to GEOS 3.9.1, GDAL 3.3.2, PROJ 7.2.1; sf_use_s2() is TRUE
espaciosverdes <- read_sf('http://cdn.buenosaires.gob.ar/datosabiertos/datasets/espacios-verdes/espacio-verde-publico.geojson', )
ncol(espaciosverdes)
## [1] 37
nrow(espaciosverdes)
## [1] 1736
colnames(espaciosverdes)
##  [1] "nombre"     "nombre_ev"  "clasificac" "patio_de_j" "apadrinada"
##  [6] "observacio" "fuente_geo" "fuente_ins" "ubicacion"  "decreto"   
## [11] "fecha_decr" "ordenanza_" "fecha_orde" "boletin_of" "fecha_bole"
## [16] "BARRIO"     "COMUNA"     "Fech_padri" "Vig_padri"  "Alc_conven"
## [21] "nom_mapa"   "id_ev_pub"  "area"       "perimeter"  "DGEV_Padri"
## [26] "Mant_2017"  "TAREAS"     "ESTADO"     "SUP_TOTAL"  "Canil"     
## [31] "Posta_aero" "Etiqueta"   "REJA"       "Hor_invier" "Hor_verano"
## [36] "Obs_reja"   "geometry"
head(espaciosverdes,4)
## Simple feature collection with 4 features and 36 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -58.44584 ymin: -34.58077 xmax: -58.43746 ymax: -34.54612
## Geodetic CRS:  WGS 84
## # A tibble: 4 × 37
##   nombre        nombre_ev clasificac patio_de_j apadrinada observacio fuente_geo
##   <chr>         <chr>     <chr>      <chr>      <chr>      <chr>      <chr>     
## 1 Escuela Scal… ESCUELA … PLAZOLETA  NO         <NA>       Redigital… USIG      
## 2 <NA>          SIN NOMB… PLAZOLETA  NO         <NA>       ESPACIOS … USIG      
## 3 Polideportiv… POLIDEPO… PARQUE     NO         <NA>       Redigital… USIG      
## 4 <NA>          SIN NOMB… PLAZOLETA  NO         <NA>       ESPACIOS … USIG      
## # … with 30 more variables: fuente_ins <chr>, ubicacion <chr>, decreto <chr>,
## #   fecha_decr <chr>, ordenanza_ <chr>, fecha_orde <chr>, boletin_of <chr>,
## #   fecha_bole <chr>, BARRIO <chr>, COMUNA <dbl>, Fech_padri <chr>,
## #   Vig_padri <chr>, Alc_conven <chr>, nom_mapa <chr>, id_ev_pub <int>,
## #   area <dbl>, perimeter <dbl>, DGEV_Padri <chr>, Mant_2017 <chr>,
## #   TAREAS <chr>, ESTADO <chr>, SUP_TOTAL <int>, Canil <chr>, Posta_aero <chr>,
## #   Etiqueta <chr>, REJA <chr>, Hor_invier <chr>, Hor_verano <chr>, …
summary(espaciosverdes)
##     nombre           nombre_ev          clasificac         patio_de_j       
##  Length:1736        Length:1736        Length:1736        Length:1736       
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##   apadrinada         observacio         fuente_geo         fuente_ins       
##  Length:1736        Length:1736        Length:1736        Length:1736       
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##   ubicacion           decreto           fecha_decr         ordenanza_       
##  Length:1736        Length:1736        Length:1736        Length:1736       
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##   fecha_orde         boletin_of         fecha_bole           BARRIO         
##  Length:1736        Length:1736        Length:1736        Length:1736       
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##      COMUNA        Fech_padri         Vig_padri          Alc_conven       
##  Min.   : 0.000   Length:1736        Length:1736        Length:1736       
##  1st Qu.: 4.000   Class :character   Class :character   Class :character  
##  Median : 8.000   Mode  :character   Mode  :character   Mode  :character  
##  Mean   : 7.692                                                           
##  3rd Qu.:11.000                                                           
##  Max.   :15.000                                                           
##                                                                           
##    nom_mapa           id_ev_pub           area             perimeter    
##  Length:1736        Min.   :   2.0   Min.   :      0.0   Min.   :    0  
##  Class :character   1st Qu.: 533.8   1st Qu.:    231.5   1st Qu.:    0  
##  Mode  :character   Median : 997.5   Median :    717.1   Median :   20  
##                     Mean   : 983.8   Mean   :   9377.8   Mean   : 2297  
##                     3rd Qu.:1431.2   3rd Qu.:   2744.2   3rd Qu.: 1000  
##                     Max.   :1882.0   Max.   :2352162.4   Max.   :15918  
##                                                                         
##   DGEV_Padri         Mant_2017            TAREAS             ESTADO         
##  Length:1736        Length:1736        Length:1736        Length:1736       
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##    SUP_TOTAL        Canil            Posta_aero          Etiqueta        
##  Min.   :    0   Length:1736        Length:1736        Length:1736       
##  1st Qu.:    0   Class :character   Class :character   Class :character  
##  Median :    0   Mode  :character   Mode  :character   Mode  :character  
##  Mean   : 1064                                                           
##  3rd Qu.:    0                                                           
##  Max.   :77100                                                           
##  NA's   :994                                                             
##      REJA            Hor_invier         Hor_verano          Obs_reja        
##  Length:1736        Length:1736        Length:1736        Length:1736       
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##           geometry   
##  MULTIPOLYGON :1736  
##  epsg:4326    :   0  
##  +proj=long...:   0  
##                      
##                      
##                      
## 

Del summary se puede extraer poca información debido al caracter predominante de datos que tienen como estructura charactar. Sin embargo podemos ver como el tamaño de los espacios verdes, un 25 por ciento tiene menos de 232 metros cuadrados. Mientras que un 50% tienen 717 metros cuadrados o menos. Por otro lado el promedio es de 9377 metros cuadrados.

Podemos igualmente intentar cambiar la estructrura, pasando a un data.frame. Para eso tenemos que sacar la variable geoespacial de geoemtria.

espaciosverdes_df = st_drop_geometry(espaciosverdes)

espaciosverdes_df = as.data.frame(unclass(espaciosverdes_df), stringsAsFactors = TRUE)

summary(espaciosverdes_df)
##                                               nombre   
##  Cantero Av 27 de Febrero                        :  8  
##  Predio Villa Olímpica (no oficial)              :  4  
##  Hungría                                         :  3  
##  Paseo del Ballet Argentino                      :  3  
##  Cancha auxiliar abierta - Club Atl. Boca Juniors:  2  
##  (Other)                                         :917  
##  NA's                                            :799  
##                                   nombre_ev              clasificac 
##  SIN NOMBRE                            :336   PLAZOLETA       :644  
##  S/D                                   :107   CANTERO CENTRAL :643  
##  SIN DENOMINACION                      : 66   PLAZA           :333  
##  CANTERO AV. 27 DE FEBRERO (no oficial):  8   PARQUE          : 56  
##  PREDIO VILLA OLIMPICA (NO OFICIAL)    :  4   JARDÍN          : 27  
##  (Other)                               :907   PATIO RECREATIVO: 17  
##  NA's                                  :308   (Other)         : 16  
##  patio_de_j                                                apadrinada  
##  NO  :1237   NO                                                 : 570  
##  SI  : 330   GATORADE                                           :  14  
##  NA's: 169   PATAGONIA FLOORING  S.A. -EN TRÁMITE DE RENOVACIÓN-:   7  
##              DIFERENTES NOMBRES                                 :   4  
##              PATAGONIA FLOORING S.A.                            :   4  
##              (Other)                                            : 119  
##              NA's                                               :1018  
##                                                                                                                                                                                               observacio 
##  ESPACIOS VERDES                                                                                                                                                                                   :318  
##  no incluidos en el nomenclador de espacios verdes                                                                                                                                                 : 37  
##  Agregado en Diciembre de 2017. Veredón verde. Dentro del denominado Barrio Municipal Alte Brown                                                                                                   : 19  
##  Canteros pertenecientes al "Paseo de las Artes Latinoamericanas"                                                                                                                                  : 17  
##  Designación Oficial según Ley 5810 en BO 5136 - 29/05/2017: denominación conjunta "Paseo de los Vecinos destacados de Villa Lugano Comuna 8" a canteros de Av Riestra e/ Larraya y Cañada de Gómez: 10  
##  (Other)                                                                                                                                                                                           :750  
##  NA's                                                                                                                                                                                              :585  
##                fuente_geo    fuente_ins 
##  DIGITALIZACION 2009:   9   E.V.  :695  
##  ESPACIOS VERDES    : 687   USIG  :851  
##  USIG               :1001   USIG 2:137  
##  NA's               :  39   NA's  : 53  
##                                         
##                                         
##                                         
##                                                                                                                            ubicacion   
##  ROCA, CNEL., AV.  E/ PORTELA Y PAZ, GRAL., AV (FALTA RELEVAR COMO SE CRUZAN LAS CALLES A FIN DE ESTABLECER LIMITES DE CANTEROS):  37  
##  CONJUNTO PLAZOLETAS HOLMBERG - CONGRESO - PLAZA - PARQUE (PROYECTO AUTOPISTA U5                                                :  22  
##  DELLEPIANE, LUIS J., TTE. GRAL., AV. E/ LARRAZABAL, AV Y ESCALADA, AV.                                                         :  17  
##  DELLEPIANE, LUIS J., TTE. GRAL., AV. E/ PAZ, GRAL., AV. - RIO NEGRO Y CAÑADA DE GOMEZ                                          :  16  
##  DISTRIBUIDOR 9 DE JULIO, AV. - AU 25 DE MAYO                                                                                   :  15  
##  (Other)                                                                                                                        :1529  
##  NA's                                                                                                                           : 100  
##      decreto          fecha_decr          ordenanza_        fecha_orde 
##  De Hecho:  57   16/10/2001:  25   45.591      :  22   18/09/2001: 29  
##  2       :  23   02/01/1992:  21   27.387      :  20   07/12/1991: 24  
##  De hecho:  22   07/11/2003:  18   LEY N° 644  :  17   09/10/2003: 20  
##  186/17  :  10   20/01/1998:  12   LEY N.º 5810:  10   23/01/1973: 19  
##  5.527   :   8   22/05/2017:  10   LEY 1.128   :   9   16/07/2002: 14  
##  (Other) : 374   (Other)   : 446   (Other)     : 625   (Other)   :633  
##  NA's    :1242   NA's      :1204   NA's        :1033   NA's      :997  
##    boletin_of       fecha_bole            BARRIO         COMUNA      
##  ACTA   : 49   24/10/2001: 27   VILLA LUGANO : 187   Min.   : 0.000  
##  1303   : 26   29/01/1973: 20   VILLA SOLDATI: 136   1st Qu.: 4.000  
##  19.205 : 22   14/11/2003: 19   PALERMO      : 121   Median : 8.000  
##  14.467 : 20   27/01/1992: 19   RETIRO       :  96   Mean   : 7.692  
##  1818   : 17   09/01/2015: 10   SAAVEDRA     :  95   3rd Qu.:11.000  
##  (Other):635   (Other)   :673   (Other)      :1095   Max.   :15.000  
##  NA's   :967   NA's      :968   NA's         :   6                   
##       Fech_padri        Vig_padri   
##  29-07-2013:  17   29-07-2016:  17  
##  03-12-2009:  10   03-12-2012:  10  
##  12-12-2013:   6   12-12-2016:   6  
##  26-07-2013:   6   26-07-2016:   6  
##  28-03-2011:   5   09-04-2015:   4  
##  (Other)   :  25   (Other)   :  25  
##  NA's      :1667   NA's      :1668  
##                                                Alc_conven  
##  Instalación y mantenimiento de estaciones aeróbicas:  15  
##  Jardinería fina, corte y limpieza                  :  14  
##  Corte y limpieza                                   :  12  
##  Puesta en valor (no incluye corte y limpieza)      :  10  
##  Puesta en valor, corte y limpieza                  :   6  
##  (Other)                                            :  10  
##  NA's                                               :1669  
##                        nom_mapa     id_ev_pub           area          
##  Cantero Av 27 de Febrero  :  8   Min.   :   2.0   Min.   :      0.0  
##  Paseo del Ballet Argentino:  3   1st Qu.: 533.8   1st Qu.:    231.5  
##  Complejo Villa Olímpica   :  2   Median : 997.5   Median :    717.1  
##  Hungría                   :  2   Mean   : 983.8   Mean   :   9377.8  
##  Martín Boneo y Villalonga :  2   3rd Qu.:1431.2   3rd Qu.:   2744.2  
##  (Other)                   :918   Max.   :1882.0   Max.   :2352162.4  
##  NA's                      :801                                       
##    perimeter     DGEV_Padri  Mant_2017  
##  Min.   :    0   SI  :  82   SI  :  83  
##  1st Qu.:    0   NA's:1654   NA's:1653  
##  Median :   20                          
##  Mean   : 2297                          
##  3rd Qu.: 1000                          
##  Max.   :15918                          
##                                         
##                                                                                               TAREAS    
##  Riego - Patio de juegos con solado antigolpes - Hamaca inclusiva - Parquización - Nuevos solados:   5  
##  Parquización - Iluminación                                                                      :   3  
##  Parquización - Nuevos solados                                                                   :   3  
##  Riego - Parquización - Nuevos solados - Nuevo mobiliario y equipamiento - Iluminación           :   3  
##  Riego - Parquización                                                                            :   2  
##  (Other)                                                                                         :  67  
##  NA's                                                                                            :1653  
##         ESTADO       SUP_TOTAL      Canil      Posta_aero  Etiqueta   
##  Finalizada:  83   Min.   :    0   -   :   7   -   :   5   NO  :   8  
##  NA's      :1653   1st Qu.:    0   NO  : 129   NO  : 104   NA's:1728  
##                    Median :    0   SI  :  58   SI  :  60              
##                    Mean   : 1064   NA's:1542   NA's:1567              
##                    3rd Qu.:    0                                      
##                    Max.   :77100                                      
##                    NA's   :994                                        
##            REJA                Hor_invier             Hor_verano  
##  SI          :  10   -              :   2   -              :   2  
##  SI (parcial):   3   8:00 a 17:45 hs:   1   8:00 a 18:45 hs:   1  
##  NA's        :1723   8:00 a 18:00 hs:   4   8:00 a 19:00 hs:   3  
##                      8:00 a 19:00 hs:   6   8:00 a 20:00 hs:   7  
##                      NA's           :1723   NA's           :1723  
##                                                                   
##                                                                   
##                                               Obs_reja   
##  Lunes cerrado. Fines de semana abre a las 9:30 hs:   1  
##  Pre cierre 30 minutos antes                      :   1  
##  Pre cierre una hora antes                        :   1  
##  Sin apertura                                     :   1  
##  Sólo con visita                                  :   1  
##  NA's                                             :1731  
## 

Según el dataset los barrios con mayor cantidad de espacios verdes son Lugano, Soldati y Palermo.

str(espaciosverdes_df)
## 'data.frame':    1736 obs. of  36 variables:
##  $ nombre    : Factor w/ 917 levels "11 de Junio de 1580",..: 189 NA 840 NA 714 707 NA NA 866 254 ...
##  $ nombre_ev : Factor w/ 894 levels "1 DE MARZO DE 1948",..: 299 816 679 816 378 581 816 816 740 66 ...
##  $ clasificac: Factor w/ 12 levels "BARRIO/COMPLEJO",..: 12 12 5 12 11 11 12 12 12 2 ...
##  $ patio_de_j: Factor w/ 2 levels "NO","SI": 1 1 1 1 2 1 1 1 1 2 ...
##  $ apadrinada: Factor w/ 113 levels "A.U.S.A. (AUTOPISTAS URBANAS S. A.)",..: NA NA NA NA 82 82 NA NA NA NA ...
##  $ observacio: Factor w/ 494 levels "Actualización de la Digitalización de todos los sectores por USIG en Mayo de 2014 - Redigitalización por USIG e"| __truncated__,..: 360 230 386 230 NA NA 230 230 241 230 ...
##  $ fuente_geo: Factor w/ 3 levels "DIGITALIZACION 2009",..: 3 3 3 3 2 2 3 3 3 3 ...
##  $ fuente_ins: Factor w/ 3 levels "E.V.","USIG",..: 2 2 2 2 1 1 2 2 2 2 ...
##  $ ubicacion : Factor w/ 1263 levels "20 DE SEPTIEMBRE - DON PEDRO DE MENDOZA, AV. - ARZOBISPO ESPINOSA - CABOTO",..: 349 349 349 656 486 485 436 436 436 614 ...
##  $ decreto   : Factor w/ 319 levels "003/007","003/009",..: NA NA NA NA 194 NA NA NA 247 137 ...
##  $ fecha_decr: Factor w/ 292 levels "01/02/1956","01/06/2018",..: NA NA NA NA 167 NA NA NA 243 203 ...
##  $ ordenanza_: Factor w/ 533 levels "1.427","1.434",..: NA NA NA NA 142 98 NA NA 418 314 ...
##  $ fecha_orde: Factor w/ 406 levels "0/12/1991","01/06/1949",..: NA NA NA NA 238 117 NA NA 50 391 ...
##  $ boletin_of: Factor w/ 469 levels "1.302","1.303",..: NA NA NA NA 143 101 NA NA 407 321 ...
##  $ fecha_bole: Factor w/ 494 levels "01/03/1966","01/04/1970",..: NA NA NA NA 295 302 NA NA 5 126 ...
##  $ BARRIO    : Factor w/ 50 levels "AGRONOMIA","ALMAGRO",..: 12 12 12 6 6 6 22 22 22 31 ...
##  $ COMUNA    : num  13 13 13 13 13 13 14 14 14 12 ...
##  $ Fech_padri: Factor w/ 22 levels "01-06-2011","02-10-2006",..: NA NA NA NA NA NA NA NA NA NA ...
##  $ Vig_padri : Factor w/ 22 levels "02-10-2009","03-12-2012",..: NA NA NA NA NA NA NA NA NA NA ...
##  $ Alc_conven: Factor w/ 15 levels "Cambio de portones de acceso",..: NA NA NA NA NA NA NA NA NA NA ...
##  $ nom_mapa  : Factor w/ 918 levels "13 de Abril de 1889 - Paseo Vecinos Destacados Villa Devoto Comuna 11",..: 82 NA 558 NA 848 841 NA NA 507 112 ...
##  $ id_ev_pub : int  2 5 6 8 9 10 11 12 13 15 ...
##  $ area      : num  1658.27 3.98 4686.06 3746.97 558.99 ...
##  $ perimeter : num  0 0 0 100 9990 ...
##  $ DGEV_Padri: Factor w/ 1 level "SI": NA NA NA NA NA 1 NA NA NA NA ...
##  $ Mant_2017 : Factor w/ 1 level "SI": NA NA NA NA NA 1 NA NA NA NA ...
##  $ TAREAS    : Factor w/ 69 levels "Extensión de riego - Patio de juegos con solado antigolpes - Hamaca inclusiva - Parquización - Nuevas postas ae"| __truncated__,..: NA NA NA NA NA 9 NA NA NA NA ...
##  $ ESTADO    : Factor w/ 1 level "Finalizada": NA NA NA NA NA 1 NA NA NA NA ...
##  $ SUP_TOTAL : int  0 0 0 NA 0 10215 NA NA NA NA ...
##  $ Canil     : Factor w/ 3 levels "-","NO","SI": NA NA NA NA NA NA NA NA NA NA ...
##  $ Posta_aero: Factor w/ 3 levels "-","NO","SI": NA NA NA NA NA NA NA NA NA NA ...
##  $ Etiqueta  : Factor w/ 1 level "NO": NA NA 1 NA NA NA NA NA NA NA ...
##  $ REJA      : Factor w/ 2 levels "SI","SI (parcial)": NA NA NA NA NA NA NA NA NA NA ...
##  $ Hor_invier: Factor w/ 4 levels "-","8:00 a 17:45 hs",..: NA NA NA NA NA NA NA NA NA NA ...
##  $ Hor_verano: Factor w/ 4 levels "-","8:00 a 18:45 hs",..: NA NA NA NA NA NA NA NA NA NA ...
##  $ Obs_reja  : Factor w/ 5 levels "Lunes cerrado. Fines de semana abre a las 9:30 hs",..: NA NA NA NA NA NA NA NA NA NA ...

Ahora el dataset cuenta con factores como su principal estructura de datos.

Clase II

espacios_lugano = filter(espaciosverdes_df, BARRIO =="VILLA LUGANO")

head(espacios_lugano,4)
##                                                                      nombre
## 1                                                                      <NA>
## 2 Po. de los Vecinos destacados de Villa Lugano Comuna 8 - Bautista Mazzini
## 3                                                                      <NA>
## 4                                                                      <NA>
##                                                                     nombre_ev
## 1                                                                  SIN NOMBRE
## 2 PASEO DE LOS VECINOS DESTACADOS DE VILLA LUGANO COMUNA 8 - BAUTISTA MAZZINI
## 3                                                                  SIN NOMBRE
## 4                                                                  SIN NOMBRE
##        clasificac patio_de_j apadrinada
## 1 CANTERO CENTRAL         NO       <NA>
## 2 CANTERO CENTRAL         NO       <NA>
## 3       PLAZOLETA         NO       <NA>
## 4 CANTERO CENTRAL         NO       <NA>
##                                                                                                                                                                                           observacio
## 1                                                                                                                                                                                    ESPACIOS VERDES
## 2 Designación Oficial según Ley 5810 en BO 5136 - 29/05/2017: denominación conjunta "Paseo de los Vecinos destacados de Villa Lugano Comuna 8" a canteros de Av Riestra e/ Larraya y Cañada de Gómez
## 3                                                                                                                                                                                    ESPACIOS VERDES
## 4                                                                                                                                                                                    ESPACIOS VERDES
##   fuente_geo fuente_ins
## 1       USIG       USIG
## 2       USIG       USIG
## 3       USIG       USIG
## 4       USIG       USIG
##                                                                                                                                                                                                     ubicacion
## 1 LARRAZABAL, AV.  E/ ROCA, CNEL., AV. Y FERNANDEZ DE LA CRUZ, FRANCISCO, GRAL., AV. (EXISTE UNA VIA DEL PREMETRO EN TODA LA LONGITUD DEL CANTERO, QUE HAY QUE RESTAR DE ESTA SUPERFICIE, PREVIO RELEVAMIENTO
## 2                                                                                                                                                                   RIESTRA, AV. E/ LARRAYA Y LARRAZABAL, AV.
## 3                                                                                                                                                                                 ARGENTINA, AV. - ZELARRAYAN
## 4                                                                                                                                         DELLEPIANE, LUIS J., TTE. GRAL., AV.- E/ MURGIONDO Y ARGENTINA, AV.
##   decreto fecha_decr   ordenanza_ fecha_orde boletin_of fecha_bole       BARRIO
## 1    <NA>       <NA>         <NA>       <NA>       <NA>       <NA> VILLA LUGANO
## 2  186/17 22/05/2017 LEY N.º 5810 04/05/2017       5136 29/05/2017 VILLA LUGANO
## 3    <NA>       <NA>         <NA>       <NA>       <NA>       <NA> VILLA LUGANO
## 4    <NA>       <NA>         <NA>       <NA>       <NA>       <NA> VILLA LUGANO
##   COMUNA Fech_padri Vig_padri Alc_conven
## 1      8       <NA>      <NA>       <NA>
## 2      8       <NA>      <NA>       <NA>
## 3      8       <NA>      <NA>       <NA>
## 4      8       <NA>      <NA>       <NA>
##                                              nom_mapa id_ev_pub    area
## 1                                                <NA>        73 359.448
## 2 Bautista Mazzini - Po. de los Vecinos de Va. Lugano        82 764.543
## 3                                                <NA>        84 291.060
## 4                                                <NA>        85 814.439
##   perimeter DGEV_Padri Mant_2017 TAREAS ESTADO SUP_TOTAL Canil Posta_aero
## 1      9980       <NA>      <NA>   <NA>   <NA>        NA  <NA>       <NA>
## 2         0       <NA>      <NA>   <NA>   <NA>        NA  <NA>       <NA>
## 3         0       <NA>      <NA>   <NA>   <NA>        NA  <NA>       <NA>
## 4      9960       <NA>      <NA>   <NA>   <NA>        NA  <NA>       <NA>
##   Etiqueta REJA Hor_invier Hor_verano Obs_reja
## 1     <NA> <NA>       <NA>       <NA>     <NA>
## 2     <NA> <NA>       <NA>       <NA>     <NA>
## 3     <NA> <NA>       <NA>       <NA>     <NA>
## 4     <NA> <NA>       <NA>       <NA>     <NA>
espacios_lugano_subset = espacios_lugano %>% select(4:8)

head(espacios_lugano_subset)
##   patio_de_j apadrinada
## 1         NO       <NA>
## 2         NO       <NA>
## 3         NO       <NA>
## 4         NO       <NA>
## 5         NO       <NA>
## 6         NO       <NA>
##                                                                                                                                                                                           observacio
## 1                                                                                                                                                                                    ESPACIOS VERDES
## 2 Designación Oficial según Ley 5810 en BO 5136 - 29/05/2017: denominación conjunta "Paseo de los Vecinos destacados de Villa Lugano Comuna 8" a canteros de Av Riestra e/ Larraya y Cañada de Gómez
## 3                                                                                                                                                                                    ESPACIOS VERDES
## 4                                                                                                                                                                                    ESPACIOS VERDES
## 5                                                                                                                                                                                    ESPACIOS VERDES
## 6                                                                                                                                                                                    ESPACIOS VERDES
##   fuente_geo fuente_ins
## 1       USIG       USIG
## 2       USIG       USIG
## 3       USIG       USIG
## 4       USIG       USIG
## 5       USIG       USIG
## 6       USIG       USIG

Seleccionamos las columnas de la 4 a la 8 porque nos interesa ver si los espacios verdes de Villa Lugano están apadrinados o no y si tienen un espacio de juegos.

En el dataset original vamos a pasar los metros cuadrados a hectareas para que sea más facil entender las dimensiones del tamaño de los espacios verdes

espaciosverdes_df = espaciosverdes_df %>% mutate(hectarea = area/10000)

summary(espaciosverdes_df$hectarea)
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
##   0.00000   0.02315   0.07171   0.93778   0.27442 235.21624

obtenemos resultados similares a nuestro análisis del comienzo, la mediana de tamaño es de tan solo 0.07 hectáreas. Para poner en contraste, una manzana (una cuadra por una cuadra) es el equivalente a una hectarea.

Ahora procedermos a ordenar el dataset en base a los espacios verdes más grandes

espaciosverdes_df = espaciosverdes_df %>% arrange(desc(area))

head(espaciosverdes_df,4)
##                               nombre                                nombre_ev
## 1                  Reserva Ecológica                        RESERVA ECOLÓGICA
## 2                          Gral. Paz                              GENERAL PAZ
## 3               Parque Indoamericano    INDOAMERICANO : PASEO DE LAS MALVINAS
## 4 Pque. Polidep. Pdte. Julio A. Roca PARQUE POLIDEPORTIVO PDTE. JULIO A. ROCA
##           clasificac patio_de_j apadrinada
## 1 PARQUE SEMIPÚBLICO         NO         NO
## 2          PLAZOLETA       <NA>       <NA>
## 3             PARQUE         SI       <NA>
## 4             PARQUE       <NA>       <NA>
##                                                                                                                                                                                               observacio
## 1                                                                                                                                                                                                   <NA>
## 2                                                                                                                                                                                                   <NA>
## 3                                                                                                         no incluidos en el nomenclador de espacios verdes - Redigitalizado por USIG en Octubre de 2014
## 4 Actualización de la Digitalización de todos los sectores por USIG en Mayo de 2014 - Redigitalización por USIG en Marzo de 2017 al separarse el sector del Parque Natural Lago Lugano (sector sudoeste)
##        fuente_geo fuente_ins
## 1 ESPACIOS VERDES       E.V.
## 2            USIG     USIG 2
## 3            USIG     USIG 2
## 4            USIG     USIG 2
##                                                                                      ubicacion
## 1        NOEL, CARLOS M., INT., AV. - RIO DE LA PLATA - MALECON (N) - EX-CIUDAD DEPORTIVA BOCA
## 2                                                                                         <NA>
## 3 LACARRA, AV. - ESCALADA, AV. - CASTAÑARES, AV. - FERNANDEZ DE LA CRUZ, FRANCISCO, GRAL., AV.
## 4                                                                                         <NA>
##   decreto fecha_decr ordenanza_ fecha_orde boletin_of fecha_bole        BARRIO
## 1     151 14/07/1980     43.609 27/06/1989     18.583 27/07/1989 PUERTO MADERO
## 2    <NA>       <NA>       <NA>       <NA>       <NA>       <NA>    VILLA REAL
## 3    <NA>       <NA>       <NA>       <NA>       <NA>       <NA> VILLA SOLDATI
## 4    <NA>       <NA>       <NA>       <NA>       <NA>       <NA> VILLA SOLDATI
##   COMUNA Fech_padri Vig_padri Alc_conven                           nom_mapa
## 1      1       <NA>      <NA>       <NA>                  Reserva Ecológica
## 2     10       <NA>      <NA>       <NA>                   Plzta. Gral. Paz
## 3      8       <NA>      <NA>       <NA>                Pque. Indoamericano
## 4      8       <NA>      <NA>       <NA> Pque. Polidep. Pdte. Julio A. Roca
##   id_ev_pub      area perimeter DGEV_Padri Mant_2017 TAREAS ESTADO SUP_TOTAL
## 1      1274 2352162.4         0       <NA>      <NA>   <NA>   <NA>         0
## 2       652 1076581.1         0       <NA>      <NA>   <NA>   <NA>        NA
## 3       943  939020.4         0       <NA>      <NA>   <NA>   <NA>         0
## 4      1341  794299.9         0       <NA>      <NA>   <NA>   <NA>         0
##   Canil Posta_aero Etiqueta REJA      Hor_invier      Hor_verano
## 1  <NA>       <NA>       NO   SI 8:00 a 18:00 hs 8:00 a 19:00 hs
## 2  <NA>       <NA>     <NA> <NA>            <NA>            <NA>
## 3    NO         SI     <NA> <NA>            <NA>            <NA>
## 4  <NA>       <NA>       NO <NA>            <NA>            <NA>
##                      Obs_reja  hectarea
## 1 Pre cierre 30 minutos antes 235.21624
## 2                        <NA> 107.65811
## 3                        <NA>  93.90204
## 4                        <NA>  79.42999

Los espacios verdes más grandes entonces son la reserva ecológica, la general paz ( sus espacios verdes, no la calzada) y el parque indoamericano.

Por otro lado, vamos a cambiarle el nombre de la columna “perimeter” por “perimetro” para mantener el idioma español en el dataste

espaciosverdes_df = rename(espaciosverdes_df, perimetro = "perimeter",patio_de_juegos = "patio_de_j",obervacion ="observacio")

colnames(espaciosverdes_df)
##  [1] "nombre"          "nombre_ev"       "clasificac"      "patio_de_juegos"
##  [5] "apadrinada"      "obervacion"      "fuente_geo"      "fuente_ins"     
##  [9] "ubicacion"       "decreto"         "fecha_decr"      "ordenanza_"     
## [13] "fecha_orde"      "boletin_of"      "fecha_bole"      "BARRIO"         
## [17] "COMUNA"          "Fech_padri"      "Vig_padri"       "Alc_conven"     
## [21] "nom_mapa"        "id_ev_pub"       "area"            "perimetro"      
## [25] "DGEV_Padri"      "Mant_2017"       "TAREAS"          "ESTADO"         
## [29] "SUP_TOTAL"       "Canil"           "Posta_aero"      "Etiqueta"       
## [33] "REJA"            "Hor_invier"      "Hor_verano"      "Obs_reja"       
## [37] "hectarea"

Vemos que efectivamente se cambiaron los nombres

Tarea número III

metros_por_barrio  =espaciosverdes_df %>% group_by(BARRIO) %>%  summarise(area_barrio = sum(area))

metros_por_barrio %>% arrange(desc(area_barrio) )
## # A tibble: 51 × 2
##    BARRIO            area_barrio
##    <fct>                   <dbl>
##  1 VILLA SOLDATI        2920417.
##  2 PUERTO MADERO        2825734.
##  3 PALERMO              2220344.
##  4 BELGRANO             1285920.
##  5 VILLA LUGANO         1194540.
##  6 VILLA REAL           1107850.
##  7 SAAVEDRA              841084.
##  8 PARQUE AVELLANEDA     540599.
##  9 NUÑEZ                 411186.
## 10 RECOLETA              336135.
## # … with 41 more rows

Se agrupó el dataset por el barrio y después se creo una nueva variable llamada area_barrio que suma el area de todos los espacios verdes de un barrio. El resultado es que Villa Soldati y Puerto Madero son los dos barrios con mayor area de espacios verdes. Esto se debe a que en esos barrrios se encuentran las reservas ecológicas de la ciudad.

Ahora vamos a trabajar con los años de los decretos de cada espacio verde para eso filtramos los que no tienen datos

espaciosverdes_df_fechas = filter(espaciosverdes_df, fecha_decr != "")

head(espaciosverdes_df_fechas,4)
##                               nombre
## 1                  Reserva Ecológica
## 2     Parque de la Raza (Aeroparque)
## 3               Ciudad Universitaria
## 4 Bosque Alegre (Depvo. M. Belgrano)
##                                        nombre_ev         clasificac
## 1                              RESERVA ECOLÓGICA PARQUE SEMIPÚBLICO
## 2                 PARQUE DE LA RAZA (AEROPARQUE) PARQUE SEMIPÚBLICO
## 3 CIUDAD UNIVERSITARIA (Denominación  Propuesta)             PARQUE
## 4      BOSQUE ALEGRE (Deportivo MANUEL BELGRANO) PARQUE SEMIPÚBLICO
##   patio_de_juegos apadrinada
## 1              NO         NO
## 2              NO         NO
## 3              NO         NO
## 4              SI         NO
##                                                                                                      obervacion
## 1                                                                                                          <NA>
## 2 Nombre anterior: Bosque Autóctono (Aeroparque). Modificado por recomendación de la Comuna 14 en Marzo de 2014
## 3                                                                                                          NULL
## 4                                                  Redigitalizado en algunos sectores por USIG en Julio de 2014
##        fuente_geo fuente_ins
## 1 ESPACIOS VERDES       E.V.
## 2 ESPACIOS VERDES       E.V.
## 3 ESPACIOS VERDES       E.V.
## 4 ESPACIOS VERDES       E.V.
##                                                                                                                                                                                                     ubicacion
## 1                                                                                                                       NOEL, CARLOS M., INT., AV. - RIO DE LA PLATA - MALECON (N) - EX-CIUDAD DEPORTIVA BOCA
## 2                                                                                                                                   OBLIGADO, RAFAEL, AV. COSTANERA  - PAMPA - SARMIENTO, AV. - VIAS F.C.G.B.
## 3 DARIO, RUBEN, AV. PROLONGACION IMAGINARIA - RIO DE LA PLATA - OBLIGADO, RAFAEL, AV. COSTANERA - CALLE ACCESO A CIUDAD UNIVERSITARIA - PROYECCION FACHADAS NORDESTE PABELLONES II, III Y BASES DE LOS PABELL
## 4                                                                                                                 OBLIGADO, RAFAEL, AV. COSTANERA  -  SCALABRINI ORTIZ, RAUL, AV. - SARMIENTO - VIAS F.C.G.B.
##   decreto fecha_decr ordenanza_ fecha_orde boletin_of fecha_bole        BARRIO
## 1     151 14/07/1980     43.609 27/06/1989     18.583 27/07/1989 PUERTO MADERO
## 2   4.913 08/11/1944       <NA>       <NA>      7.280 09/11/1944       PALERMO
## 3    NULL       NULL       NULL       NULL       NULL       NULL      BELGRANO
## 4   4.913 08/11/1944       <NA>       <NA>      7.280 09/11/1944       PALERMO
##   COMUNA Fech_padri Vig_padri Alc_conven                           nom_mapa
## 1      1       <NA>      <NA>       <NA>                  Reserva Ecológica
## 2     14       <NA>      <NA>       <NA>      Pque. de la Raza (Aeroparque)
## 3     13       <NA>      <NA>       <NA>               Ciudad Universitaria
## 4     14       <NA>      <NA>       <NA> Bosque Alegre (Depvo. M. Belgrano)
##   id_ev_pub      area perimetro DGEV_Padri Mant_2017 TAREAS ESTADO SUP_TOTAL
## 1      1274 2352162.4         0       <NA>      <NA>   <NA>   <NA>         0
## 2      1109  659422.0         0       <NA>      <NA>   <NA>   <NA>         0
## 3      1313  530293.7         0       <NA>      <NA>   <NA>   <NA>         0
## 4      1335  134893.3         0       <NA>      <NA>   <NA>   <NA>         0
##   Canil Posta_aero Etiqueta REJA      Hor_invier      Hor_verano
## 1  <NA>       <NA>       NO   SI 8:00 a 18:00 hs 8:00 a 19:00 hs
## 2  <NA>       <NA>     <NA> <NA>            <NA>            <NA>
## 3  <NA>       <NA>       NO <NA>            <NA>            <NA>
## 4  <NA>       <NA>     <NA> <NA>            <NA>            <NA>
##                      Obs_reja  hectarea
## 1 Pre cierre 30 minutos antes 235.21624
## 2                        <NA>  65.94220
## 3                        <NA>  53.02937
## 4                        <NA>  13.48933

Luego creamos una nueva variable con el nombre anio_decr, usamos el subsetting de string para sacar los 4 caracteres desde la izquierda de la fecha del decreto, lo cual nos deja con el anio del mismo.

espaciosverdes_df_fechas = espaciosverdes_df_fechas %>% mutate(anio_decr = str_sub(fecha_decr,-4,-1))
head(espaciosverdes_df_fechas,4)
##                               nombre
## 1                  Reserva Ecológica
## 2     Parque de la Raza (Aeroparque)
## 3               Ciudad Universitaria
## 4 Bosque Alegre (Depvo. M. Belgrano)
##                                        nombre_ev         clasificac
## 1                              RESERVA ECOLÓGICA PARQUE SEMIPÚBLICO
## 2                 PARQUE DE LA RAZA (AEROPARQUE) PARQUE SEMIPÚBLICO
## 3 CIUDAD UNIVERSITARIA (Denominación  Propuesta)             PARQUE
## 4      BOSQUE ALEGRE (Deportivo MANUEL BELGRANO) PARQUE SEMIPÚBLICO
##   patio_de_juegos apadrinada
## 1              NO         NO
## 2              NO         NO
## 3              NO         NO
## 4              SI         NO
##                                                                                                      obervacion
## 1                                                                                                          <NA>
## 2 Nombre anterior: Bosque Autóctono (Aeroparque). Modificado por recomendación de la Comuna 14 en Marzo de 2014
## 3                                                                                                          NULL
## 4                                                  Redigitalizado en algunos sectores por USIG en Julio de 2014
##        fuente_geo fuente_ins
## 1 ESPACIOS VERDES       E.V.
## 2 ESPACIOS VERDES       E.V.
## 3 ESPACIOS VERDES       E.V.
## 4 ESPACIOS VERDES       E.V.
##                                                                                                                                                                                                     ubicacion
## 1                                                                                                                       NOEL, CARLOS M., INT., AV. - RIO DE LA PLATA - MALECON (N) - EX-CIUDAD DEPORTIVA BOCA
## 2                                                                                                                                   OBLIGADO, RAFAEL, AV. COSTANERA  - PAMPA - SARMIENTO, AV. - VIAS F.C.G.B.
## 3 DARIO, RUBEN, AV. PROLONGACION IMAGINARIA - RIO DE LA PLATA - OBLIGADO, RAFAEL, AV. COSTANERA - CALLE ACCESO A CIUDAD UNIVERSITARIA - PROYECCION FACHADAS NORDESTE PABELLONES II, III Y BASES DE LOS PABELL
## 4                                                                                                                 OBLIGADO, RAFAEL, AV. COSTANERA  -  SCALABRINI ORTIZ, RAUL, AV. - SARMIENTO - VIAS F.C.G.B.
##   decreto fecha_decr ordenanza_ fecha_orde boletin_of fecha_bole        BARRIO
## 1     151 14/07/1980     43.609 27/06/1989     18.583 27/07/1989 PUERTO MADERO
## 2   4.913 08/11/1944       <NA>       <NA>      7.280 09/11/1944       PALERMO
## 3    NULL       NULL       NULL       NULL       NULL       NULL      BELGRANO
## 4   4.913 08/11/1944       <NA>       <NA>      7.280 09/11/1944       PALERMO
##   COMUNA Fech_padri Vig_padri Alc_conven                           nom_mapa
## 1      1       <NA>      <NA>       <NA>                  Reserva Ecológica
## 2     14       <NA>      <NA>       <NA>      Pque. de la Raza (Aeroparque)
## 3     13       <NA>      <NA>       <NA>               Ciudad Universitaria
## 4     14       <NA>      <NA>       <NA> Bosque Alegre (Depvo. M. Belgrano)
##   id_ev_pub      area perimetro DGEV_Padri Mant_2017 TAREAS ESTADO SUP_TOTAL
## 1      1274 2352162.4         0       <NA>      <NA>   <NA>   <NA>         0
## 2      1109  659422.0         0       <NA>      <NA>   <NA>   <NA>         0
## 3      1313  530293.7         0       <NA>      <NA>   <NA>   <NA>         0
## 4      1335  134893.3         0       <NA>      <NA>   <NA>   <NA>         0
##   Canil Posta_aero Etiqueta REJA      Hor_invier      Hor_verano
## 1  <NA>       <NA>       NO   SI 8:00 a 18:00 hs 8:00 a 19:00 hs
## 2  <NA>       <NA>     <NA> <NA>            <NA>            <NA>
## 3  <NA>       <NA>       NO <NA>            <NA>            <NA>
## 4  <NA>       <NA>     <NA> <NA>            <NA>            <NA>
##                      Obs_reja  hectarea anio_decr
## 1 Pre cierre 30 minutos antes 235.21624      1980
## 2                        <NA>  65.94220      1944
## 3                        <NA>  53.02937      NULL
## 4                        <NA>  13.48933      1944

ahora podemos agrupar por fechas y por barrios

resumen_barrial <- espaciosverdes_df_fechas %>%
  group_by(anio_decr, BARRIO) %>%
  summarise(area = sum(area))
## `summarise()` has grouped output by 'anio_decr'. You can override using the
## `.groups` argument.
resumen_barrial
## # A tibble: 344 × 3
## # Groups:   anio_decr [74]
##    anio_decr BARRIO          area
##    <chr>     <fct>          <dbl>
##  1 0-09      FLORES       10149. 
##  2 1-44      RECOLETA        10.1
##  3 1-50      RETIRO       32368. 
##  4 1-96      RECOLETA     15786. 
##  5 1-97      VILLA LUGANO  2443. 
##  6 1908      MONSERRAT     2176. 
##  7 1926      SAAVEDRA     12473. 
##  8 1927      BELGRANO       482. 
##  9 1931      BARRACAS      2172. 
## 10 1931      RECOLETA      5244. 
## # … with 334 more rows

Ahora tenemos las fechas de creacion de las plazas por barrio. Es tiempo de pivotear para ver mejor la información

resumen_wider <- pivot_wider(resumen_barrial, 
                                       names_from = BARRIO, 
                                       values_from = area)  

resumen_wider
## # A tibble: 74 × 49
## # Groups:   anio_decr [74]
##    anio_decr FLORES RECOLETA RETIRO `VILLA LUGANO` MONSERRAT SAAVEDRA BELGRANO
##    <chr>      <dbl>    <dbl>  <dbl>          <dbl>     <dbl>    <dbl>    <dbl>
##  1 0-09      10149.     NA      NA             NA        NA       NA       NA 
##  2 1-44         NA      10.1    NA             NA        NA       NA       NA 
##  3 1-50         NA      NA   32368.            NA        NA       NA       NA 
##  4 1-96         NA   15786.     NA             NA        NA       NA       NA 
##  5 1-97         NA      NA      NA           2443.       NA       NA       NA 
##  6 1908         NA      NA      NA             NA      2176.      NA       NA 
##  7 1926         NA      NA      NA             NA        NA    12473.      NA 
##  8 1927         NA      NA      NA             NA        NA       NA      482.
##  9 1931         NA    5244.     NA             NA        NA       NA       NA 
## 10 1934         NA      NA      NA             NA        NA       NA       NA 
## # … with 64 more rows, and 41 more variables: BARRACAS <dbl>, ALMAGRO <dbl>,
## #   `NUEVA POMPEYA` <dbl>, `PARQUE AVELLANEDA` <dbl>, `SAN CRISTOBAL` <dbl>,
## #   `VILLA GRAL. MITRE` <dbl>, `PARQUE PATRICIOS` <dbl>, `VILLA LURO` <dbl>,
## #   `VILLA ORTUZAR` <dbl>, `VILLA PUEYRREDON` <dbl>, PALERMO <dbl>,
## #   `VILLA DEVOTO` <dbl>, `MONTE CASTRO` <dbl>, `VILLA URQUIZA` <dbl>,
## #   BALVANERA <dbl>, VERSALLES <dbl>, LINIERS <dbl>, `VILLA REAL` <dbl>,
## #   `VILLA DEL PARQUE` <dbl>, COLEGIALES <dbl>, CONSTITUCION <dbl>, …

Con pivot wider se pasó de tener a los barrios como varaible en filas para pasarlos a columna, de esta forma se puede ver como fue la historia de creacion de espacios verdes en los barrios y además entender la cantidad de metros que se sumaron dependiendo el año.

Parece que la creación por año nos deja la información tan desagregada que no nos deja detectar patrones, por lo que agregaremos una columna que ponga las décadas para cada año.

espaciosverdes_df_fechas <- espaciosverdes_df_fechas %>%
  mutate(decada = case_when(
    anio_decr < 1910 ~ "1900", 
    anio_decr < 1920 ~ "1910", 
    anio_decr < 1930 ~ "1920", 
    anio_decr < 1940 ~ "1930", 
    anio_decr < 1950 ~ "1940", 
    anio_decr < 1960 ~ "1950", 
    anio_decr < 1970 ~ "1960", 
    anio_decr < 1980 ~ "1970", 
    anio_decr < 1990 ~ "1980", 
    anio_decr < 2000 ~ "1990", 
    anio_decr < 2010 ~ "2000",
    anio_decr < 2020 ~ "2010",
    is.na(anio_decr) ~ "Sin datos"
  ))

Repetimos el group_by con summarie y el pivot wider

resumen_barrial <- espaciosverdes_df_fechas %>%
  group_by(decada, BARRIO) %>%
  summarise(area = sum(area))
## `summarise()` has grouped output by 'decada'. You can override using the
## `.groups` argument.
resumen_barrial
## # A tibble: 200 × 3
## # Groups:   decada [12]
##    decada BARRIO         area
##    <chr>  <fct>         <dbl>
##  1 1900   FLORES       10149.
##  2 1900   MONSERRAT     2176.
##  3 1900   RECOLETA     15796.
##  4 1900   RETIRO       32368.
##  5 1900   VILLA LUGANO  2443.
##  6 1920   BELGRANO       482.
##  7 1920   SAAVEDRA     12473.
##  8 1930   ALMAGRO       7513.
##  9 1930   BARRACAS      2172.
## 10 1930   FLORES         327.
## # … with 190 more rows
resumen_wider <- pivot_wider(resumen_barrial, 
                                       names_from = BARRIO, 
                                       values_from = area)  

resumen_wider
## # A tibble: 12 × 49
## # Groups:   decada [12]
##    decada FLORES MONSERRAT RECOLETA RETIRO `VILLA LUGANO` BELGRANO SAAVEDRA
##    <chr>   <dbl>     <dbl>    <dbl>  <dbl>          <dbl>    <dbl>    <dbl>
##  1 1900   10149.     2176.   15796. 32368.          2443.      NA       NA 
##  2 1920      NA        NA       NA     NA             NA      482.   12473.
##  3 1930     327.       NA     5244.    NA             NA       NA       NA 
##  4 1940      NA        NA       NA     NA          10154.      NA   180836.
##  5 1950   80822.       NA    84015.  5649.            NA     2402.      NA 
##  6 1960    2135.       NA     7872. 10291.           705.   19963.     721.
##  7 1970      NA     18055.    6436.    NA           3496.    9089.   14473.
##  8 1980      NA      1554.    3741.  2654.          3381.    4476.    3216.
##  9 1990   14515.      145.  102305.  6038.          1156.   59403.   30698.
## 10 2000    6656.      157.    4459.  1994.         11625.    7868.   60694.
## 11 2010    2863.     4761.   14125.    NA           3063.   18681.    1649.
## 12 <NA>      NA        NA       NA     NA             NA   530294.      NA 
## # … with 41 more variables: ALMAGRO <dbl>, BARRACAS <dbl>,
## #   `NUEVA POMPEYA` <dbl>, `PARQUE AVELLANEDA` <dbl>, `PARQUE PATRICIOS` <dbl>,
## #   `SAN CRISTOBAL` <dbl>, `VILLA GRAL. MITRE` <dbl>, `VILLA LURO` <dbl>,
## #   `VILLA ORTUZAR` <dbl>, BALVANERA <dbl>, `MONTE CASTRO` <dbl>,
## #   PALERMO <dbl>, `VILLA DEVOTO` <dbl>, `VILLA PUEYRREDON` <dbl>,
## #   `VILLA URQUIZA` <dbl>, LINIERS <dbl>, VERSALLES <dbl>,
## #   `VILLA DEL PARQUE` <dbl>, `VILLA REAL` <dbl>, BOCA <dbl>, …

Podemos ver como la información se muestra más claramente a nivel de década. Por ejemplo, no se crea un espacio públci en villa gral mitre desde 1930, que se tenga datos.

Ahora vamos a ver cuanto representan los espacios verdes de cada barrio como el total del área

#Barrios#

barrios <- st_read('https://bitsandbricks.github.io/data/CABA_barrios.geojson')
## Reading layer `CABA_barrios' from data source 
##   `https://bitsandbricks.github.io/data/CABA_barrios.geojson' 
##   using driver `GeoJSON'
## Simple feature collection with 48 features and 4 fields
## Geometry type: POLYGON
## Dimension:     XY
## Bounding box:  xmin: -58.53152 ymin: -34.70529 xmax: -58.33514 ymax: -34.52754
## Geodetic CRS:  WGS 84
barrios
## Simple feature collection with 48 features and 4 fields
## Geometry type: POLYGON
## Dimension:     XY
## Bounding box:  xmin: -58.53152 ymin: -34.70529 xmax: -58.33514 ymax: -34.52754
## Geodetic CRS:  WGS 84
## First 10 features:
##              BARRIO COMUNA PERIMETRO    AREA                       geometry
## 1         CHACARITA     15  7725.695 3118101 POLYGON ((-58.45282 -34.595...
## 2          PATERNAL     15  7087.513 2229829 POLYGON ((-58.46558 -34.596...
## 3      VILLA CRESPO     15  8132.699 3613584 POLYGON ((-58.42375 -34.597...
## 4  VILLA DEL PARQUE     11  7705.390 3399596 POLYGON ((-58.49461 -34.614...
## 5           ALMAGRO      5  8537.901 4050752 POLYGON ((-58.41287 -34.614...
## 6         CABALLITO      6 10990.964 6851029 POLYGON ((-58.43061 -34.607...
## 7  VILLA SANTA RITA     11  5757.752 2153691 POLYGON ((-58.48192 -34.624...
## 8      MONTE CASTRO     10  7361.036 2627481 POLYGON ((-58.50349 -34.624...
## 9        VILLA REAL     10  5070.966 1334146 POLYGON ((-58.52512 -34.614...
## 10           FLORES      7 15772.425 8590784 POLYGON ((-58.44525 -34.642...

Traemos el dataset barrios y lo mergeamos con el de espacios verdes. Lo podríamos hacer con un st_join pero como todavía no nos interesa la información georeferenciada vamos a sacarle tambien la geometría

barrios_df = st_drop_geometry(barrios)
barrios_df = as.data.frame(barrios_df, stringsasfactors=TRUE)
str(barrios_df)
## 'data.frame':    48 obs. of  4 variables:
##  $ BARRIO   : chr  "CHACARITA" "PATERNAL" "VILLA CRESPO" "VILLA DEL PARQUE" ...
##  $ COMUNA   : num  15 15 15 11 5 6 11 10 10 7 ...
##  $ PERIMETRO: num  7726 7088 8133 7705 8538 ...
##  $ AREA     : num  3118101 2229829 3613584 3399596 4050752 ...
espaciosverdes_consolidado = espaciosverdes_df  %>% group_by(BARRIO) %>% summarise(area = sum(area))


espaciosverdes_df_barrios = left_join(espaciosverdes_consolidado, barrios)
## Joining, by = "BARRIO"
espaciosverdes_df_barrios = espaciosverdes_df_barrios %>% group_by(BARRIO) %>% summarise(area = sum(area), AREA = max(AREA))

espaciosverdes_df_barrios
## # A tibble: 51 × 3
##    BARRIO        area     AREA
##    <chr>        <dbl>    <dbl>
##  1 AGRONOMIA    2834. 2122169.
##  2 ALMAGRO      8758. 4050752.
##  3 BALBANERA    1207.      NA 
##  4 BALVANERA   28967. 4342280.
##  5 BARRACAS   185682. 7961000.
##  6 BELGRANO  1285920. 7932303.
##  7 BOCA        92683. 5028581.
##  8 BOEDO       12127. 2609774.
##  9 CABALLITO  215695. 6851029.
## 10 CHACARITA   93358. 3118101.
## # … with 41 more rows
espaciosverdes_df_barrios = rename(espaciosverdes_df_barrios, Area_Espacios_Publicos = "area", Area_Barrial = "AREA")
espaciosverdes_df_barrios
## # A tibble: 51 × 3
##    BARRIO    Area_Espacios_Publicos Area_Barrial
##    <chr>                      <dbl>        <dbl>
##  1 AGRONOMIA                  2834.     2122169.
##  2 ALMAGRO                    8758.     4050752.
##  3 BALBANERA                  1207.          NA 
##  4 BALVANERA                 28967.     4342280.
##  5 BARRACAS                 185682.     7961000.
##  6 BELGRANO                1285920.     7932303.
##  7 BOCA                      92683.     5028581.
##  8 BOEDO                     12127.     2609774.
##  9 CABALLITO                215695.     6851029.
## 10 CHACARITA                 93358.     3118101.
## # … with 41 more rows

Ahora queremos conocer el ratio de area de espacios publicos sobre el area total del barrio, usamos la función mutate

espaciosverdes_df_barrios = espaciosverdes_df_barrios %>% mutate(ratio_areas = Area_Espacios_Publicos/Area_Barrial)

espaciosverdes_df_barrios = espaciosverdes_df_barrios %>% arrange(desc(ratio_areas))


espaciosverdes_df_barrios
## # A tibble: 51 × 4
##    BARRIO            Area_Espacios_Publicos Area_Barrial ratio_areas
##    <chr>                              <dbl>        <dbl>       <dbl>
##  1 VILLA REAL                      1107850.     1334146.      0.830 
##  2 PUERTO MADERO                   2825734.     5027425.      0.562 
##  3 VILLA SOLDATI                   2920417.     8663595.      0.337 
##  4 BELGRANO                        1285920.     7932303.      0.162 
##  5 SAAVEDRA                         841084.     5538677.      0.152 
##  6 PALERMO                         2220344.    15772496.      0.141 
##  7 VILLA LUGANO                    1194540.     9296142.      0.128 
##  8 PARQUE AVELLANEDA                540599.     4732708.      0.114 
##  9 NUÑEZ                            411186.     4349736.      0.0945
## 10 PARQUE PATRICIOS                 249476.     3743507.      0.0666
## # … with 41 more rows

Podemos ver que los barrios con mayor proporción son villa real, uerto mader y villa Soldati.

Clase IV

Ahora trabajaremos sobre gráficos y diferentes formas de presentar la información de nuestros datasets.

En primer lugar analizaremos una variable continua, en nuestro caso puede ser el tamaño en metros cuadrados de los espacios verdes de CABA.

Para poder entender estas variables se puede hacer tanto por un gráfico de densidad como por un histograma.

ggplot(filter(espaciosverdes_df, clasificac =="PARQUE" | clasificac =="PLAZA"))+
  geom_density(aes(x=area))+
  labs(title="Area de parques y plazas de CABA",
       fill="Zona",
       x="Area (M2)",
       y="Distribución de la variable area",
       caption="Fuente: Datos abiertos del GCBA")+
  scale_fill_viridis_d() +
  theme_bw() + facet_wrap(~clasificac)

ggplot(filter(espaciosverdes_df, clasificac =="PARQUE" | clasificac =="PLAZA"))+
  geom_histogram(aes(x=area, fill=clasificac), bins =50)+
  labs(title="Area de parques y plazas de CABA",
       fill="Zona",
       x="Area (M2)",
       y="Concentración de la información",
       caption="Fuente: Datos abiertos del GCBA")+
    scale_fill_manual(values = c("goldenrod2", "indianred2"))+
  theme_bw()

Ahora veremos si a medida que se fueron incrementando los años tambien se fueron incorporando los espacios públicos creados.

library("hrbrthemes")
## NOTE: Either Arial Narrow or Roboto Condensed fonts are required to use these themes.
##       Please use hrbrthemes::import_roboto_condensed() to install Roboto Condensed and
##       if Arial Narrow is not on your system, please see https://bit.ly/arialnarrow

Realizamos un gropub_by sin el barrio para tener un resumen a nivel de la ciudad

resumen_barrial <- espaciosverdes_df_fechas %>%
  group_by(decada ) %>%
  summarise(area = sum(area))

resumen_barrial
## # A tibble: 12 × 2
##    decada     area
##    <chr>     <dbl>
##  1 1900     62931.
##  2 1920     12956.
##  3 1930     56722.
##  4 1940   1054696.
##  5 1950    279588.
##  6 1960    136151.
##  7 1970    130630.
##  8 1980   2665897.
##  9 1990    490876.
## 10 2000    629964.
## 11 2010    118136.
## 12 <NA>    530294.
resumen_barrial  %>%
  ggplot( aes(x= decada, y=area)) +
    geom_line( color="grey", size =3 ) +
    geom_point(shape=21, color="black", fill="#69b3a2", size=3.5) +
    theme_ipsum() +
    ggtitle("Area de espacios verdes por decada de creación") + labs( y="Superficie cubierta (M2)", caption="Fuente: Elaboración propia en base a GCBA") + scale_y_continuous(labels = function(x) format(x, scientific = FALSE))
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family not
## found in Windows font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family not
## found in Windows font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family not
## found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

El presente gráfico se realizó para comprender la fecha de creación de los espacios verdes de la ciudad autónoma de buenos aires. Agrupado por década de creación. Podemos ver claramente como la decada de creacion de mas espacios verdes es la decada de 1980. Salvo esa decada en particular, no se destacan grandes avances en materia de creacion de espacio verde y público.

Area por barrio

ggplot(espaciosverdes_df_barrios)  + geom_bar(aes(x=reorder(BARRIO, ratio_areas), weight=ratio_areas, fill=Area_Espacios_Publicos
)) +
  geom_text(aes(x=BARRIO, y=ratio_areas, label=paste(round(ratio_areas,2),"%")), size=3.5, color="black", position = position_dodge(width=0.9), hjust=-0.25)+
  labs(title="Porcentaje de espacios verdes sobre el total del area del barrio",
       subtitle="CABA",
       fill="Area_espacios_publicos",
       x="Partido",
       y="Porcentaje",
       caption="Fuente: GCBA") +
  scale_fill_viridis_c() +
  theme_light() +
  coord_flip()
## Warning: Removed 3 rows containing missing values (geom_text).

Realizamos un grafico de barras para poder entender como es la composición de los espacios verdes en la ciudad de buenos aires por barrio y tambien por tamaño de barrio. El porcentaje es del total de espacios verdes sobre el total del area del barrio. Podemos ver que villa santa rita casi no tiene espacios verdes. Podemos ver como habiamos mencionado anteriormente que el barrio con mas porcentaje de espacios verdes es el de Villa real, sin embargo por el color nos damos cuenta que no es de los que más tiene en general.

resumen_barrial <- espaciosverdes_df_fechas %>%
  group_by(decada, BARRIO ) %>%
  summarise(area = sum(area))
## `summarise()` has grouped output by 'decada'. You can override using the
## `.groups` argument.
resumen_barrial
## # A tibble: 200 × 3
## # Groups:   decada [12]
##    decada BARRIO         area
##    <chr>  <fct>         <dbl>
##  1 1900   FLORES       10149.
##  2 1900   MONSERRAT     2176.
##  3 1900   RECOLETA     15796.
##  4 1900   RETIRO       32368.
##  5 1900   VILLA LUGANO  2443.
##  6 1920   BELGRANO       482.
##  7 1920   SAAVEDRA     12473.
##  8 1930   ALMAGRO       7513.
##  9 1930   BARRACAS      2172.
## 10 1930   FLORES         327.
## # … with 190 more rows

Agrupamos la creacion de espacios verdes por decada y por barrio

ggplot(resumen_barrial)  + geom_bar(aes(x=reorder(decada, decada), weight=area, fill=BARRIO
))  +
  scale_fill_viridis_d() +
  theme_light() +
  coord_flip()
## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

Realizamos un primer acercamiento sobre como graficar la información, pero todavía no es del todo clara.

ggplot(resumen_barrial)  + geom_bar(aes(x=reorder(BARRIO, area), weight=area, fill= decada
))  +
  labs(title="Tamaño de espacios verdes por barrio y fecha de creacion",
       subtitle="CABA",
       fill="Area_espacios_publicos",
       x="Barrio",
       y="Tamaño de espacios verdes en M2",
       caption="Fuente: GCBA") +
  scale_fill_viridis_d() +
  theme_light() +
  coord_flip()

Elegimos mostrar por barrio la cantidad de espacios verdes creados por decadas. Para entender como fue el desarrollo y el crecimiento de los mismos a lo largo del tiempo. Concluimos que el barrio donde más espacios verdes se crearon fue en 1980 y especificamente en Puerto Madero.

Tarea V

1.a. Mapa coroplético que muestre la distribución geográfica de una variable numérica.

resumen_barrial = left_join(resumen_barrial, barrios)
## Joining, by = "BARRIO"
resumen_barrial= st_as_sf(resumen_barrial)
ggplot() +
  geom_sf(data = resumen_barrial, aes(geometry = resumen_barrial$geometry , fill = area )) +  
  scale_fill_viridis_c() +
  labs(title = "Espacios verdes creados por barrio y fecha",
       subtitle = "CABA - Mayo 2021",
       fill = "Tamaño en metros cuadrados",
       caption = "Fuente: CABA") + facet_wrap(~decada)

resumen_barrial =  filter(resumen_barrial, area <2000000) 
 ggplot() +
  geom_sf(data = resumen_barrial, aes(geometry = resumen_barrial$geometry , fill = area )) +  
  scale_fill_viridis_c() +
  labs(title = "Densidad",
       subtitle = "CABA - Mayo 2021",
       fill = "Densidad poblacional (hab./km2)",
       caption = "Fuente: CABA") + facet_wrap(~decada)

1.b. Mapa coroplético que muestre la distribución geográfica de una variable categórica.

Tipologia_predominante =  espaciosverdes_df %>%
  group_by(clasificac, BARRIO ) %>%
  summarise(Tipologia = n())
## `summarise()` has grouped output by 'clasificac'. You can override using the
## `.groups` argument.
Tipologia_predominante = left_join(Tipologia_predominante, barrios)
## Joining, by = "BARRIO"
resumen_barrial= st_as_sf(resumen_barrial)
 ggplot() +
  geom_sf(data = Tipologia_predominante, aes(geometry = Tipologia_predominante$geometry , fill = Tipologia )) +  
  scale_fill_viridis_c() +
  labs(title = "Densidad",
       subtitle = "CABA - Mayo 2021",
       fill = "Densidad poblacional (hab./km2)",
       caption = "Fuente: CABA") + facet_wrap(~clasificac)

1.c. Elegir uno de los mapas anteriores e incorporarle una o más geometrías que sean relevantes al análisis.

campanas = read_sf("https://cdn.buenosaires.gob.ar/datosabiertos/datasets/subsecretaria-de-higiene-urbana/campanas-verdes/campanas-verdes.geojson")
Plazas_Por_Barrio = espaciosverdes %>% filter(clasificac =="PLAZA", BARRIO !="BALBANERA")

Plazas_Por_Barrio = st_drop_geometry(Plazas_Por_Barrio)

Plazas_Por_Barrio = Plazas_Por_Barrio %>% group_by(BARRIO) %>% summarise(plaza = n())
Plazas_Por_Barrio = left_join(Plazas_Por_Barrio, barrios)
## Joining, by = "BARRIO"
Plazas_Por_Barrio= st_as_sf(Plazas_Por_Barrio)

No me gusta

library("mapview")
mapview(Plazas_Por_Barrio, zcol = "plaza", na.rm = TRUE) + mapview(campanas)